package com.landian.commons.jpa.criteria;

import com.landian.commons.jpa.builder.PredicateFactory;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

/**
 *
 * @author caojl
 * @create 2017/11/29
 **/
class KeyWordPredicable implements Predicable {

    private String keyWord;

    private com.querydsl.core.types.Path[] dslPaths;

    private KeyWordPredicable(String keyWord, com.querydsl.core.types.Path<?>... dslPaths) {
        this.keyWord = keyWord;
        this.dslPaths = dslPaths;
    }

    public static KeyWordPredicable newInstance(String keyWord, com.querydsl.core.types.Path<?>... dslPaths) {
        return new KeyWordPredicable(keyWord, dslPaths);
    }

    @Override
    public Predicate build(Root<?> root, CriteriaBuilder cb) {
        return PredicateFactory.keyWord(root, cb, keyWord, dslPaths);
    }
}